package com.tangsm.spring.boot.strategy.demo.biz;

import com.tangsm.spring.boot.strategy.demo.annotation.MessageTransports;
import com.tangsm.spring.boot.strategy.demo.domain.Message;
import com.tangsm.spring.boot.strategy.demo.enums.MessageTypeEnum;
import com.tangsm.spring.boot.strategy.demo.base.SendMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * EMAIL-邮件消息策略业务接口实现类
 * @author tangsm
 */
@MessageTransports(MessageTypeEnum.EMAIL)
@Service
public class SendEmailMessage implements SendMessage {
    private static final Logger log = LoggerFactory.getLogger(SendEmailMessage.class);
    /**
     * 发送消息验证码接口
     *
     * @param message 消息参数
     * @return 响应结果
     */
    @Override
    public String send(Message message) {
        String msg = String.format("SendEmailMessage：%s发送%s成功",
                message.getTarget(),
                MessageTypeEnum.getNameByCode(message.getType()));
        log.info(msg);
        return msg;
    }
}
